<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\index\controller;


/**
 * 前端首页控制器
 */
class Index extends IndexBase
{
    
    // 首页
    public function index()
    {     
        $this->getAllColumn();
        
        $this->assign('column_id',1);
        
        //获取首页轮播图
        $where['category_id'] = 1;
        $this->assign('advert_list', $this->logicArticle->getArticleList($where,'a.cover_id'));
        
        //获取简介
        $about = $this->logicArticle->getArticleInfo(['category_id'=>25],'a.content,a.name');
        
        $about['content'] = $about?html_entity_decode($about['content']):'';
        
        $this->assign('about',$about);
        
        //获取新闻列表
        $where_news['category_id'] = array('in','14,15,16');
        $this->assign('news',$this->logicArticle->getIndexNewsList($where_news, 'a.id,a.name,a.updated_at','is_index,sort,updated_at'));
        
        //获取公司成就
        $this->assign('achievement',$this->logicOurResult->getIndexResultList(['is_index'=>1],'id,result_descrit','sort'));
        
        //获取合作客户
        $this->assign('customer',$this->logicCustomer->getIndexCustomerList([],'id,logo_id,campany_name','sort'));
        
        //获取咨询师
        $this->assign('consultant',$this->logicConsultant->getIndexConsultantList(['is_index'=>1],'id,photo_id,describe,consultant_name','sort'));
        
         //获取合作客户友情链接
        $this->assign('link',$this->logicFriendship->getIndexFriendshipList([],'friend_url,cover_id,friend_tittle','sort'));
        
        //获取联系方式
        $this->assign('contact',$this->logicContact->getContactInfo());
        
        return $this->fetch('index');
    }
    
    
    /**
     * 新闻资讯
     */
    public function news()
    {
        $this->getAllColumn();
        
        $this->assign('column_id',5);
        
        $where['category_id'] = 14;
        
        if(array_key_exists('category_id', $this->param)){
            
            $where['category_id'] = $this->param['category_id'];
        }

        $this->assign('list',$this->logicArticle->getArticleList3($where));
        
        $this->assign('category', $where['category_id']);
        
         //获取联系方式
        $this->assign('contact',$this->logicContact->getContactInfo());
        
        return $this->fetch('news');
    }
    
    
    /**
     * 新闻详情
     * @return type
     */
    public function newsDetail()
    {
        $this->getAllColumn();
        
        $this->assign('column_id',5);
        
        $this->assign('info',$this->logicArticle->getArticleInfo(['a.id'=>$this->param['id']]));
        
         //获取联系方式
        $this->assign('contact',$this->logicContact->getContactInfo());
        
        return $this->fetch('news_secondary');
    }
    
    /**
     * 资源中心  
     */
    public function resourcesIdea()
    {
        $this->getAllColumn();
        
        $this->assign('column_id',6);
        
        $where['category_id'] = 18;

        $this->assign('list',$this->logicArticle->getArticleList3($where));
        
        $this->assign('category', $where['category_id']);
        
         //获取联系方式
        $this->assign('contact',$this->logicContact->getContactInfo());
        
        return $this->fetch('resources_idea');
    }
    
    
    /**
     * 技术中心详情
     * @return type
     */
    public function resourcesDetail()
    {
        $this->getAllColumn();
        
        $this->assign('column_id',6);
        
        $this->assign('info',$this->logicArticle->getArticleInfo(['a.id'=>$this->param['id']]));
        
         //获取联系方式
        $this->assign('contact',$this->logicContact->getContactInfo());
        
        return $this->fetch('resources_detail');
    }
 
    /**
     * 资源中心-技术转让
     * @return type
     */
    public function resourcesChange()
    {
        $this->getAllColumn();
        
        $this->assign('column_id',6);
        
        $where['category_id'] = 17;
        
        $this->assign('list',$this->logicArticle->getArticleList3($where));
        
        $this->assign('category', $where['category_id']);
        
         //获取联系方式
        $this->assign('contact',$this->logicContact->getContactInfo());
        
        return $this->fetch('resources_change');
    }
    
    
    public function joinTalent()
    {
        $this->getAllColumn();
        
        $this->assign('column_id',7);
        
        $where['status'] = 1;
        
        $this->assign('list',$this->logicForjob->getJobsList($where));
        
//        $this->assign('contact',$this->logicArticle->getArticleInfo(['category_id'=>20]));
        
         //获取联系方式
        $this->assign('contact',$this->logicContact->getContactInfo());
                
        return $this->fetch('join_talent');
    }
    
    public function map()
    {
        $this->getAllColumn();
        
        $this->assign('column_id',7);
        
         //获取联系方式
        $this->assign('contact',$this->logicContact->getContactInfo());
        
        return $this->fetch('map');
    }
    
    public function joinMap()
    {
        $this->getAllColumn();
        
        $this->assign('column_id',7);
        
         //获取联系方式
        $this->assign('contact',$this->logicContact->getContactInfo());
        
        return $this->fetch('map');
    }
    
    
    /**
     * 搜索
     */
    public function search()
    {
        $this->getAllColumn();
        
        $this->assign('column_id',1);
        
         //获取联系方式
        $this->assign('contact',$this->logicContact->getContactInfo());

        $this->assign('list',$this->logicBussiness->getSearchList($this->param));
        
        $search = array_key_exists('search', $this->param)?$this->param['search']:'';
        
        $this->assign('search',$search);
        
        return $this->fetch('search');
    }
   
}
